import os
import yaml

from base.constant import config_path, out_folder


def get_config():
    if not os.path.exists(config_path):
        print("配置文件不存在")
        exit(0)
    file = open(config_path, 'r')
    return yaml.safe_load(file), file


def create_folders():
    check_path(out_folder)


def check_path(file_path: str):
    directory = os.path.dirname(file_path)
    if not os.path.exists(directory):
        os.makedirs(directory)
    return file_path
